package com.zzx.tool;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zzx.domain.PackageInfo;
import com.zzx.dto.UserDemandDTO;
import com.zzx.service.PackageInfoService;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Component
public class MyTools {
    @Autowired
    private PackageInfoService packageInfoService;

    @Tool(description = "根据用户传输的信息查询对应的套餐")
    public List<PackageInfo> getPackageInfo(@ToolParam(description = "用户传输的数据") UserDemandDTO dto) {
        //查全部
        //select * from packageInfo where monthly_fee <= ? and data_allowance >= ? and call_duration >= ?
        LambdaQueryWrapper<PackageInfo> lqw = new LambdaQueryWrapper<>();
        lqw.le(PackageInfo::getMonthlyFee, dto.getBudget());
        lqw.ge(PackageInfo::getDataAllowance, dto.getTraffic());
        lqw.ge(PackageInfo::getCallDuration, dto.getCallDuration());
        List<PackageInfo> list = packageInfoService.list(lqw);
        return list;
    }

    @Tool(description = "查询全部套餐供用户参考")
    public List<PackageInfo> getAll() {
        return packageInfoService.list();
    }
}
